﻿#ifndef NctiDisplayDCMGeometry_H
#define NctiDisplayDCMGeometry_H
#include "dcl_ncti_object.h"
#include "NctiDisplayGModelObject.h"
#include "NctiDCMDef.h"
#include "NctiDCMEXVec2d.h"
namespace NCTI
{
	class DECL_NCTI_OBJECT NctiHelpNode
	{
		NCTI_G_NODE m_g;
		NCTI_D_NODE m_d;

	public:
		NctiHelpNode(NCTI_G_NODE gi, NCTI_D_NODE di) { m_g = gi, m_d = di; }
		NCTI_G_NODE geometry() { return m_g; }
		NCTI_D_NODE dimension() { return m_d; }
	};
	class NctiDCMParametric;
	class NctiDisplayDCMDimSys;
	class NctiDisplayModelBody;
	class NctiDCMSet;
	class DECL_NCTI_OBJECT NctiDisplayDCMGeometry : public NctiDisplayGModelObject
	{
		NCTI_DISPLAYOBJECT_FUNCTIONS(NctiDisplayDCMGeometry)
			//NCTI_DISPLAYOBJECT_REQUIRE_INSTANCE_REDRAW
	public:
		virtual ~NctiDisplayDCMGeometry();
	public:
		virtual void Init();
		virtual EnumNctiResult UpdateDisplay();
	private:
		NCTI_READ_AND_WRITE_VERSION_FUN(1)
			ncti_g_node_status m_fstat;
		NCTI_G_NODE m_gnode;
		NctiDisplayDCMDimSys* m_DimSys;
		Ncti_Char* m_flabel;
		NctiDisplayModelBody* m_ModelBody;
		NctiDCMSet* m_fowner;
		NctiDisplayDCMGeometry* m_base;

	protected:
		//temp
		Ncti_Boolean m_IsModify;
		Ncti_Boolean m_IsTransform;
		Ncti_Boolean m_IsDrag;
		Ncti_Double m_transformmat[3][3];
		Ncti_Double m_lastTransformmat[3][3];
	public:
		void ResetTransform() { m_IsTransform = false; }
		void ResetModify() { m_IsModify = false; }
		Ncti_Boolean IsModify() { return m_IsModify; }
		void Modify() { m_IsModify = true; }

		void ResetMatrix();
		void SetDrag(bool boo) { m_IsDrag = boo; }
		Ncti_Boolean IsDrag() const { return m_IsDrag; }
		Ncti_Boolean IsChanged() const { return m_IsTransform || m_IsModify; }
	public:
		virtual ncti_DCM_g_type identify() const {return NCTI_DCM_UNKNOWN;}
		virtual NctiDCMEXGType type() const { return EX_UNKNOWN; }
		virtual void transform(Ncti_Double i_mat[3][3]);
		virtual std::string describe() const;
		virtual NCTI_DCM_logical copy_values(const NctiDisplayDCMGeometry*) { return NCTI_DCM_FALSE; }
		virtual NCTI_G_NODE add_to_dcm(NctiDisplayDCMDimSys* i_pDimSys);
		virtual void offset_transform_mx(double o_mat[3][3], const double i_distance, const NctiDCMEXVec2d& i_dir);
	
	public:
		NctiDisplayDCMGeometry* get_base() const { return m_base; }
		void set_base(NctiDisplayDCMGeometry* i_base) { m_base = i_base; }
		NctiDCMSet* get_owner() const { return m_fowner; }
		void set_owner(NctiDCMSet* i_set) { m_fowner = i_set; }

		void set_status(ncti_g_node_status i_stat);
		ncti_g_node_status status() const { return m_fstat; }
		NCTI_G_NODE get_g_node()  const { return m_gnode; }
		void set_g_node(NCTI_G_NODE i_gn);
		NctiDisplayDCMDimSys* get_dcm() const { return m_DimSys; }
		void set_dcm(NctiDisplayDCMDimSys* i_pDimSys);
		void set_label(const Ncti_Char* i_new_label);
		const Ncti_Char* label_c_str() const { return m_flabel; }
		void SetModelBody(NctiDisplayModelBody* i_pModelBody);
		NctiDisplayModelBody* GetModelBody() const { return m_ModelBody; }

		Ncti_Boolean Get_transformType() const{ return m_IsTransform; }
		void Set_transformType(Ncti_Boolean i_isTransform) { m_IsTransform = i_isTransform; }
		void Get_transformmat(Ncti_Double o_mat[3][3]) const;
		void Get_lastTransformmat(Ncti_Double o_mat[3][3]) const;
	};
}
#endif
